package main

import (
	"fmt"
	"gitee.com/shijun123456/kcgin/logs"
	"pool"
)

type User struct {
}

func (this *User) Do(i interface{}) (interface{}, error) {
	logs.Info("参数: %v", i)
	var res interface{}
	switch i.(type) {
	case string:
		res = i.(string) + "sin"
	case int:
		res = i.(int) + 1
	}
	logs.Info("结果: %v", res)
	return res, nil
}
func main() {
	var wf pool.WorkFlow

	//初始化并启动工作
	user := new(User)
	wf.StartWorkFlow(10, 100)
	for i := 0; i < 100; i++ {
		payload := pool.Payload{
			fmt.Sprintf("产品:%08d", i+1),
		}
		wJob := pool.Job{
			Payload: payload,
			Process: user,
		}
		//添加工作
		wf.AddJob(wJob)
	}
	wf.CloseWorkFlow()
}
